Part Number Hot Search : 
APM4548 K15A60U 1N759D MAX2745 ZL40815 54N06 LD411060 MAX4294
Product Description
Full Text Search
 

To Download AN1353 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  january 2006 rev 2 1/17 AN1353 application note asd st62000c software description for cooling thermostat applicatons 1 introduction in this document, we explain the software of an electronic thermostat bread board. the demonstration kit has been developped by stmicroelectronics and is available under therm01eval reference. this board illustrates the operation of a low cost electronic thermostat for 220-240v 50hz cold appliances, including stmicroelectronics acs102-5ta, acst6-7st and st62 devices. the microcontroller will ensure four functions: temperature regulation (temperature capture through ntc resistor + hysteresis regulation). compressor monitoring: the motor is controlled depending on fridge temperature. to start it, the starting triac ts and the run triac tr are triggered simultaneously for 500ms. then, only the run triac will continue to conduct. overcurrent detection: this is based on the measure of the peak current using a shunt resistor. during the one second (500 ms+500 ms) of starting transient, this routine does not run. internal light bulb control. 2 hardware configuration 2.1 general information the power supply of the microcontroller is a capacitive one. its particularity is that the vss is 5v less than the neutral. this power supply can be called a ?negative supply?. this generates flowing out current from the acs/acst gates (acs are triggered only with a negative gate current). this feature must also be kept in mind when the overcurrent detection is implemented. it will define in which polarity the current can be sensed. figure 1 illustrates the board electrical circuit. www.st.com
hardware configuration AN1353 2/17 rev 2 figure 1. bread-board schematic note the following features on the mcu hardware environment: the clock is achieved by the internal oscillator no external reset circuit is used, thanks to the low voltage detector option of the mcu the zero voltage crossing (zvc) event is sensed through r6 by the nmi pin. 2.2 i/o port configuration the following table explains what the i/o ports are used for, and how they are configured, beginning with the port b which is configured in input (except for pb1 which is configured as a push pull output). all the inputs are configured with a pull up resistor, except for when they are used as an adc input. no in-terrupt is active on any of these pins. all port a pins are configured as push pull outputs. table 2 details the option choices and configuration reg-isters. s2 doorswitch r14 51r r4 360r r1 33r 1/2w r8 62k run j1 bulb 1 2 start l_pcb 6h c7 2.2nf c6 1nf c1 470nf x2 vdd c4 10 nf x2 u1 st62t00c 2 3 16 14 15 13 12 11 10 9 8 7 4 6 5 1 oscin oscout vss pa 2 pa 1 pa 3 pb0/ain pb1/ain pb3/ain pb5/ain pb6/ain pb7/ain nmi rst vpp/test vdd r10 50m 1/2 w j2 ntc 1 2 6v2 1.3w d2 f1 fuse 6 a / 250 v r11 47r 1/2 w r3 160r r5 1.5k r6 470k d1 led c9 2.2nf r12 1k + 2200f / 10 v c3 r7 33k r9 47k tb bulb acs102 ts run acst6 tr start acst6 j3 door 1 2 vdd d3 r2 160r n j4 motor 1 2 3 100k pot a c8 2.2nf l c12 1 f c11 680pf l c2 100nf c5 1nf c10 2.2nf vdd j5 mains 1 2 3 r13 51r table 1. port b configuration registers pin name use ddr or dr pb0 not used 0 0 0 pb1 switch on the led / switch off the led 1 1 0/1 pb2 not existing for st6200 0 0 0 pb3 shunt voltage analog input / input with pull up 0 1/0 1/0 pb4 not existing for st6200 0 0 0 pb5 temperature order analog input / input with pull up 0 1/0 1/0 pb6 door switch information 0 0 0 pb7 cabinet temperature analog input / input with pull up 0/0 1/0 1/0
AN1353 main program rev 2 3/17 3 main program 3.1 mains period measurement as the board does not embed an oscillator or resonator, the internal resonator of the mcu is used to achieve the clock. but, in this case, the running frequency is given within a range of 20%. this is not enough to ensure an optimum pulse gate current control with a power consumption as little as possible. to increase the timer accuracy, the mcu uses the zero voltage crossing (zvc) events to have time infor-mation. the line voltage is connected to the nmi pin through a high impedance resistor. an interruption will then occur at each zvc event. the mcu has just to launch the timer decrementation between two nmi interrupts to calculate how much one must load the tcr register to count down 20 ms. of course, in normal operation, the timer can be used for other tasks than counting the mains period. the period measurement will then be based on the rest of time from the last timer utilization and the next nmi interrupt. this measured time is saved as deltat (see figure 2 ) by the software. the 20 ms will then equal the deltat, plus the sum of times t1 to t3, plus the time lost due to calculator operations between each timer stop and launch (see section 4.3 ). note: such a method is only valid when the mains frequency is know in advance; i.e. for a board dedicated to one range of ac mains voltage. in our case, the software and hardware are dedicated to 220/240 v 50 hz applications. table 2. port a configuration registers pin name use ddr or dr pa1 start acst6 on / start acst6 off 1 1 0/1 pa2 run acst6 on / run acst6 off 1 1 0/1 pa3 light bulb on / light bulb off 1 1 0/1
main program AN1353 4/17 rev 2 figure 2. timing definition 3.2 subroutines execution time checking in order not to miss the timer interrupt events, the cpu must be completely free and ready to check the timer interrupt flag. this means that all subroutines must be completed before the expected end of the timer decrementation. figure 2 shows that the subroutines are placed at different moments, depending on their length. for exam-ple, the longest cpu action is when the mcu calculates the t1 to t5 delays. this action can last up to more than 7.2 ms for a 4 mhz mcu clock frequency. then, there is not enough time available between two timer interrupts to calculate these five values. this is the reason why the delay calculation subroutine has been split into two parts (calcul-delay_1 and calcul-delay_2). these two parts are respectively placed during t4 and deltat decounts ta b l e 3 gives the maximum duration of each subroutine (for a 4 mhz clock frequency, and the for the lon-gest software loops). ta b l e 4 gives the code execution maximum times for all the instructions written in the software, before each subroutine (?code execution time? column). then, according to the implemented durations, the time, still available for the cpu, is given with a 0.2 ms safety margin. subroutines pa1 / pa2 pa 3 t1 t2 t3 t4 t5 deltat nmi calcul delay 1 motor status current measure calcul delay 2 loads control mains voltage table 3. subroutines maximum durations subroutine name maximum time loads_control 0.93 ms motor_status 0.26 ms current_measure 0.92 ms calcul_delay_1 1.75 ms calcul_delay_2 5.49 ms
AN1353 main program rev 2 5/17 3.3 start-up and smart reset at each reset interrupt, the program first checks if the data stored in the ram are as scheduled or not. in-deed, a reset can occur without the supply voltage having fallen below vrm (data retention parameter: 0.7 v). in this case, a whole start-up is not necessary, and the program can keep working with the previous ram data. this is helpful in order to avoid missing loads control when a reset occurs, due to an emi problem for example. if the checked ram registers are not as expected, then a complete initialization procedure is launched (see appendix b ). this routine, among other things, configures the a and b ports, waits 100 ms before go on (wait-ing for the stabilization of the supply), and measures the mains period for the first time. if the ram area is adequate, then a ?smart reset? can be performed. only the registers which are used to store internal sub-routines variables are cleared. only the main registers keep their previous values (motor status, etc.). it is important to note that this start-up procedure can miss firing some loads during one mains cycle. this is why, if the motor was at start-up state before a ?smart reset?, it is better to stop the motor. this avoids switching both the tr and ts devices on together when the split phase capacitor can be charged (refer to an1354). this is done by simply setting to high level the overcurrent detection flag. table 4. cpu available time name duration (ms) code execution time (ms) subroutines time sum (ms) available time (ms) t1 0.45 0.25 0 0 t2 1.05 0.13 0 0.72 t3 1.75 0.13 0 1.42 t4 3.95 0.85 (t50 hz average) 1.75 1.15 t5 2.80 0.09 0.26 + 0.92 1.33 deltat 6.75 0.08 5.49 + 0.93 0 total 4.62
gate current pulses AN1353 6/17 rev 2 4 gate current pulses 4.1 general description the gate current pulses are generated during the main program (refer to appendix a and also to figure 2 ). the port a pins are set or reset depending on the information defined by the sub-routines described in para-graph 5. annex 1 gives the flowchart of the main program. the zvc events are sensed thanks to bit 0 of the flag register, which is only set during the nmi interrupt. the end of timer decrementations are also sensed by bit 1 of the flag register, which is set during timer interrupt. first, as soon as the zvc is detected, the t1 decrementation is launched and the light bulb is switched on, if requested, by pulling pa3 down to vss. after the timer interrupt, pa2 and pa3 are set, or not, depending on the process status. after t2 decrementation, pa3 is set and a new decrementation is launched (t3) to wait to turn off both tr and ts. after this pulse generation, the timer counts down t4 to synchronize the current measure to the moment at which it reaches its peak value. after the ?current_measure? sub-routine, t5 is decremented in order to reach the beginning of the next half cycle. gate current pulses are then generated as in the previous cycle. 4.2 how to change the pulse duration? all the pulse durations are based on a one half-cycle time reference basis. indeed, in order to count the pe-riod time, the timer is launched after the last current pulse, when vln is positive. deltat will then always represent a time shorter than 10 ms. to be sure that the timer overflow will never occur before the next nmi interrupt, we must ensure that the time to decrement 256 will be always higher than 10 ms. this condition can be reached with a 32 prescalar ratio. with such a value, even with the maximum allowed mcu clock frequency, the overflow will happen in 12.28 ms. t50hz = deltat + t1 +t2 +t3, then represents the value to load in the tscr register to achieve a 10 ms overflow period. to define an ?n? ms duration, consider the following relation: so, tx must be loaded in the tscr to have a timer interrupt after ?n? ms. however, as a division by ten is not easy to implement, and in order to increase the register accuracy, it is better to use variables in the range of 256. the variable ?dx? is used and defined as explained below: 10 ms t50hz n (ms) tx ? ? ? tx = t50hz x n (ms) 10 dx = n x 256 10
AN1353 gate current pulses rev 2 7/17 when, tx can be calculated as follows: dividing by 256 is thus easily achieved simply by considering the most significant byte of the multiplication result of t50hz and dx.the dx variables are defined in the constants list at the beginning of the software. to implement new pulse timings, only the values in this list have to be changed. for 60 hz applications, the ?10ms? used in the calculation should be replaced by 8.33. 4.3 influence of the code time in fact, the timer is not launched exactly when it has to be. this is due to the time required by the mcu to perform some instructions between the last interrupt and the effective decrementation beginning. for example, before the launch of the first t1 decrementation, the program must run the nmi interrupt, save the deltat result, write port a and the start the timer. these 47 instructions all in all last 200 s for a 4 mhz mcu clock frequency. then, to ensure that the gate current will be applied on the tr and ts de-vices at the right time, it is better to cut off this delay from t1. furthermore, this delay will vary depending on the mcu clock frequency (fcpu), which will vary according to the junction temperature and the supply voltage level. so, a method is required to remove the code delay whatever fcpu is. first, we know that the oscillator frequency is divided by 13 to drive the cpu core. therefore, ?n? cpu cy-cles last 13xn/fcpu seconds. secondly, the cpu oscillator frequency is divided by 12 to drive the timer, and then divided by the division factor programmed in the tscr register. in our case, the division factor is 32 during the main program loop. therefore, one unit timer counter equals 12x32/fcpu. based on the previous formula, we can easily convert n cycles code execution time to the timer counter value (tcode), as shown below. for example, the length of the code time for 47 cycles approximately equals one unit of the timer counter. then, one must be subtracted from t1 in order to rectify the gate current pulse delay from the code execution delay. for t2 and t3, it does not matter if the code execution delay is removed or not. indeed, it is not a problem that the gate current pulses last longer. for t4, it is important to begin the current measure at the right time. the 98 cycles must then be subtracted from t4. this leads to subtract 3 from the tscr register value. when the half-cycle duration is calculated, the code execution time must also be added to t50hz. as 110 cycles are performed, 4 must be added to the t50hz value. tx = t50hz x dx 256 x tcode = = n x n x 13 13 12 x 13 f cpu 384 f cpu
sub-routines AN1353 8/17 rev 2 4.4 timing example ta b l e 5 gives the values which must be loaded into the tscr register to implement a 1.5 ms pulse (to trig-ger the light) and a 0.45 ms delayed pulse of 2.8 ms length (to trigger the both windings of the motor). these are the values programmed by default in the therm01eval board microcontroller. 5 sub-routines 5.1 load control this sub-routine defines which load has to be turned on (refer to appendix c ). the light bulb is then controlled de-pending on the door switch information. it is the sensed temperature, the order set by the external potenti-ometer and the hysteresis law, described in figure 3 , that instructs the motor to be on. order 1, the upper limit, equals the temperature order set by an external potentiometer plus a threshold value (which can be changed, refer to ?thres? in the constants list). order 2 equals the same order minus this threshold. figure 3. temperature hysteresis control table 5. tscr values to implement the required pulses name delay (ms) tscr value (decimal) t1 0.45 (-code delay) 12 -1 t2 1.05 27 t3 1.75 45 t4 3.95 (-code delay) 101 -3 order 2 order 1 temperature motor on motor off
AN1353 sub-routines rev 2 9/17 this sub-routine also defines if the motor must be started up. if the temperature becomes higher than order 1, the compressor should be started. but, care must be taken not to start the motor if it is already on. otherwise, ts could be switched on when tr is already on, resulting in a capacitor discharge through the two devices. note that each evaporator temperature and potentiometer voltage measurements are refreshed every 256 cycles (by the average value of the previous 256 cycles). this means that the temperature control is acti-vated every 5 seconds. 5.2 motor status this sub-routine defines which acst must be triggered depending on the motor state and the order asked by the ?loads_control? routine. this flowchart is shown on annex 4. when the motor is required to be on, both tr and ts are switched on 500 ms. after that, only tr is fired, if the motor must still be on. in this case, the motor_status routine claims that the motor is in a transient state again for 500 ms. this state is used by the ?current_measure? sub-routine. indeed, the current must not be measured during the first one second of operation, during which the current is high. on the other hand, if the current remains high after this one second, that means that an abnormal condition has occurred (stall rotor for example) and it is better to stop the motor. 5.3 current measure the current measure is only performed when the motor should be on, and if it is not at start-up transient state. at each overcurrent detection, the motor is stopped, a led is switched on during 5 s, and, of course, the current measure is no longer performed. the overcurrent detection is, in fact, based on an average of four measures. this is done to reduce emi noise. the over current therefore always acts with at least an 80 ms delay, because only one measure by cycle is done. the measured value is compared to the ?vlimit? constant. a 242 value equals a voltage of 5.22 v at the in-put of the analog to digital converter (for a 5.5 v supply). as the measure is achieved thanks to a 50 mohm shunt, referenced to the vdd, this value is similar to a 5.6 a current. such a current means that the rotor is stalled because, in steady state, a 100-300 w compressor always sinks a current lower than 3 a.
conclusion AN1353 10/17 rev 2 6 conclusion this paper has presented how a software for st6200c mcus has been developed for thermostat applica-tions. the main goals of this software are: low cost: no external resonator is used even if good accuracy for time control is required. this is achieved thanks to a mains period based calculation method. no external reset circuit is needed thanks the mcu lvd option. low consumption: all acs and acst devices are triggered by pulsed gate currents in order to reduce the average current consumption. noise immunity: the noise immunity has been increased by several software techniques (smart reset, adc results averaging). the hardware watch-dog option must also be activated and unused program memory space can be filled as described in the an435 application note. this paper will help users to adapt the software to their own requirements. the following data in particular must be checked: peak current measure moment (t5 register) gate current pulses delay & duration maximum peak current value to detect an over current (vlimit constant) temperature control hysteresis threshold.
AN1353 main program flowchart rev 2 11/17 appendix a main program flowchart figure 4. main program flowchart main prog wait for zvc event save tcr in deltat starts t1 decrementation writes pa3 output data wait for timer interrupt starts t2 decrementation set pa3 output wait for timer interrupt starts t3 decrementation set pa3 output wait for timer interrupt set pa1 output set pa2 output negative cycle passed ? start timer decrementation call calcul_delay_2 call loads_control main prog next reset nmi flag start t4 decrementation first cycle passed ? decrementation count5 sum(t50hz) < - sum(t50hz) + t50hz + t1 + t2 + t3 + deltat + 4 count5 = 0? sum(t50hz) < -sum(t50hz) / 4 count5 < -2 call calcul_delay_1 wait for timer interrupt start t5 decrementation call current_measure call motor_status next no yes no yes yes no
start-up procedure AN1353 12/17 rev 2 appendix b start-up procedure figure 5. start-up procedure reset ram data ok ? sub-routines internal variables initialization wait 100 ms registers initialization port a&b configuration write ?check-ram? registers measure mains period (t50hz) start-up = 1 ? over-current < -1 switch off tr&ts port a&b configuration outputs writing main_prog no yes no yes
AN1353 loads_control sub-routine rev 2 13/17 appendix c loads_control sub-routine figure 6. loads_control flowchart loads_control fridge door open ? motor start-up allowed switch on the motor read temperature order order 1 < - order + thres order 2 < - order - thres switch on the light switch off the light temperature > order 1? motor start-up not allowed temperature > order 2? switch off the motor motor on ? motor start-up not allowed ret no yes yes yes no no yes
motor_status procedure AN1353 14/17 rev 2 appendix d motor_status procedure figure 7. motor_status flowchart motor_status motor should be on ? switch on ts switch on tr counter 1 < -25 counter 2 < -25 switch off the motor (ts & tr) decrement counter 1 over current = 1 ? start-up in progress ? counter 1 < 0 ? motor start-up not allowed transient state < -1 switch on ts switch on tr transient state = 1 ? decrement counter 2 counter 2 < 0 ? ret transient state < - 0 counter 2 < - 25 no no yes yes no no yes yes yes no yes no
AN1353 current_measure procedure rev 2 15/17 appendix e current_measure procedure figure 8. current_measure flowchart over current = 1 ? motor should be on ? transient state = 1 ? current_measure decrement counter 4 measure shunt voltage vshunt < - vshunt + measure vshunt < - vshunt / 4 counter 4 < - 4 decrement counter 3 ret counter 4 < 0 ? vshunt > vlimit ? back back counter 3 < - 250 counter 4 < - 4 vshunt < - 0 over_current < - 1 switch on the led counter 3 < 0 ? over-current < - 0 switch off the led counter 3 < - 250 yes no no yes yes no yes yes yes no no no
revision history AN1353 16/17 rev 2 revision history table 6. document revision history date revision changes apr-2001 1 initial release. 24-jan-2006 2 reformatted to current standard. minor changes to figures 1, 2, 7, and 8.
AN1353 rev 2 17/17 the present note which is for guidance only, aims at providing customers with information regarding their products in order for them to save time. as a result, stmicroelectronics shall not be held liable for any direct, indirect or consequential damages with respect t o any claims arising from the content of such a note and/or the use made by customers of the information contained herein in connection with their products. information furnished is believed to be accurate and reliable. however, stmicroelectronics assu mes no responsibility for the co nsequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. no license is granted by implication or otherwise under any patent or patent rights of stmicroelectronics. specifications mentioned in this publicati on are subject to change without notice. this publication supersedes and replaces all information previously supplied. stmicroelectronics prod ucts are not authorized for use as critical components in life support devices or systems without express written approval of stmicroelectro nics. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners ? 2006 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia - belgium - brazil - canada - china - czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of AN1353

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X